CompileOpt= -c -O2 -w1 -I./include/ -DWorkshopPath=\"SERVER\"
LinkOpt= -L/usr/local/lib

object_share = gaussian_integration.o gsl_app.o MatAlgebra.o parameters.o pulseseq.o
object_core = GaussianNoise.o Noise.o
object_special = noise_app.o spectrum.o

exec = gaussian-noise

logfile = MakeInfo.log
version = Version.log

ObjShareDir = ../obj/share
ObjSpecialDir = ../obj/special
ObjCoreDir = ../obj/core
BinDir = ../bin

SrcShareDir = ./source/share
HeadShareDir = ./include/share

SrcCoreDir = ./source/core
HeadCoreDir = ./include/core

SrcSpecDir= ./source/special
HeadSpecDir= ./include/special

#NeedLib = -lgsl -lgslcblas -lmkl_intel -lmkl_intel_thread -lmkl_core -lguide -lpthread
NeedLib = -lgsl -lgslcblas -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -lguide -lpthread

VPATH = $(SrcShareDir) : $(SrcCoreDir) : $(SrcSpecDir) \
: $(HeadShareDir) : $(HeadCoreDir) : $(HeadSpecDir) \
: $(ObjShareDir) : $(ObjSpecialDir) : $(ObjCoreDir)

#bin
$(BinDir)/MakeInfo: $(BinDir)/$(exec) 
	date > $(BinDir)/$(logfile)
	svn update > $(BinDir)/$(version)

$(BinDir)/$(exec): $(object_share) $(object_core) $(object_special)
	icpc $(LinkOpt) $(ObjShareDir)/*.o $(ObjCoreDir)/*.o $(ObjSpecialDir)/*.o -o $(BinDir)/$(exec) $(NeedLib) 

#core	
$(ObjCoreDir)/GaussianNoise.o: GaussianNoise.cpp Usrdef.h parameters.h spectrum.h Noise.h MatAlgebra.h gaussian_integration.h pulseseq.h
	icpc $(CompileOpt) $(SrcCoreDir)/GaussianNoise.cpp -o $(ObjCoreDir)/GaussianNoise.o

$(ObjCoreDir)/Noise.o: Noise.cpp Usrdef.h globalvar.h Noise.h parameters.h gsl_app.h MatAlgebra.h
	icpc $(CompileOpt) $(SrcCoreDir)/Noise.cpp -o $(ObjCoreDir)/Noise.o
	
#comm
$(ObjShareDir)/gaussian_integration.o: gaussian_integration.cpp gaussian_integration.h
	icpc $(CompileOpt) $(SrcShareDir)/gaussian_integration.cpp -o $(ObjShareDir)/gaussian_integration.o

$(ObjShareDir)/gsl_app.o: gsl_app.cpp Usrdef.h gsl_app.h
	icpc $(CompileOpt) $(SrcShareDir)/gsl_app.cpp -o $(ObjShareDir)/sl_app.o

$(ObjShareDir)/MatAlgebra.o: MatAlgebra.cpp Usrdef.h MatAlgebra.h
	icpc $(CompileOpt) $(SrcShareDir)/MatAlgebra.cpp -o $(ObjShareDir)/MatAlgebra.o		

$(ObjShareDir)/parameters.o: parameters.cpp Usrdef.h parameters.h
	icpc $(CompileOpt) $(SrcShareDir)/parameters.cpp -o $(ObjShareDir)/parameters.o	

$(ObjShareDir)/pulseseq.o: pulseseq.cpp Usrdef.h parameters.h globalvar.h
	icpc $(CompileOpt) $(SrcShareDir)/pulseseq.cpp -o $(ObjShareDir)/pulseseq.o	

#Spec
$(ObjSpecialDir)/noise_app.o: noise_app.cpp Usrdef.h globalvar.h Noise.h parameters.h gsl_app.h MatAlgebra.h pulseseq.h
	icpc $(CompileOpt) $(SrcSpecDir)/noise_app.cpp -o $(ObjSpecialDir)/noise_app.o

$(ObjSpecialDir)/spectrum.o: spectrum.cpp Usrdef.h globalvar.h Noise.h parameters.h spectrum.h
	icpc $(CompileOpt) $(SrcSpecDir)/spectrum.cpp -o $(ObjSpecialDir)/spectrum.o
		
.PHONY: clean
clean:
	-rm -f $(ObjShareDir)/*.o $(ObjSpecialDir)/*.o $(ObjCoreDir)/*.o \
$(BinDir)/* $(BinDir)/$(logfile)
